const globalIp = getApp().globalData.userIp
Page({

  /**
   * 页面的初始数据
   */
  data: {
    nameCall: '精确搜索',
    nameColor: false,
    nameFlag: false,
    projectList: [],
    info:'',
  },

  getInputValue:function(e) {
    this.setData({
      info: e.detail.value
    })
  },

  selectData: function(){
    this.alreadyShow();
  },

  nameShow: function () {//综合下拉
    if (this.data.nameFlag){
      this.setData({
        nameFlag : !this.data.nameFlag,
      })
    }else{
      this.setData({
        nameFlag: !this.data.nameFlag,
      })
    }
  },

  alreadyShow: function(){
    var that = this;
    wx.showLoading({
      title: '数据加载中...',
    })
    wx.request({
      url: globalIp + 'home/oitm/selPurUserSCFFShip',
      data: {
        openId: wx.getStorageSync('userInfo').openid || '',
        cardCode: wx.getStorageSync('userInfo').CardCode || '',
        opinion: that.data.info,
        value: '4'
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'POST',
      success: function(res) {
        if (res.data.jsonObject) {
          var data = res.data.jsonObject.data;
          var arr = [];
          var res = [];
          for (var i in data) {
            arr[i] = [];
            for(var j in data[i]) {
              arr[i].push(data[i][j]);
            }
          }
          for (var i = 0; i < arr[0].length; ++i) {
            res[i] = [];
            for (var j = 0; j < arr.length; ++j) {
              res[i][j] = arr[j][i];
            }
          } 
          that.setData({
            projectList: res
          })
        } else {
          wx.showToast({
            title: '请返回上一页面，重新请求',
            icon: 'none',
            duration: 2000,
          })
        }
      },
      complete: () => {
        wx.hideLoading()
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.alreadyShow();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },
})